#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int majorityElement(vector<int>& nums) {
        unordered_map<int, int> m1;
        double half = nums.size() / 2;
        for (auto& e : nums)
        {
            m1[e]++;
        }
        for (auto& e : m1)
        {
            if (e.second > half)
            {
                return e.first;
            }
        }

        return -1;
    }
};